// GeneralOptionPage.cpp : implementation file
//

#include "stdafx.h"
#include "kwclientcore.h"
#include "GeneralOptionPage.h"
#include "ClientConfiguration.h"
#include "MainPanel.h"

#include "CommonLib\Structure.h"

#include "GUIBaseLib\TopPropertySheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGeneralOptionPage property page

IMPLEMENT_DYNCREATE(CGeneralOptionPage, CPropertyPage)

CGeneralOptionPage::CGeneralOptionPage() : CPropertyPage(CGeneralOptionPage::IDD)
{
	//{{AFX_DATA_INIT(CGeneralOptionPage)
	m_strHomePageURL = _T("");
	//}}AFX_DATA_INIT
}

CGeneralOptionPage::~CGeneralOptionPage()
{
}

void CGeneralOptionPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGeneralOptionPage)
	DDX_Text(pDX, IDC_EDIT_HOMEPAGEURL, m_strHomePageURL);
	DDV_MaxChars(pDX, m_strHomePageURL, 128);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGeneralOptionPage, CPropertyPage)
	//{{AFX_MSG_MAP(CGeneralOptionPage)
	ON_EN_CHANGE(IDC_EDIT_HOMEPAGEURL, OnChangeEditHomepageurl)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGeneralOptionPage message handlers

void CGeneralOptionPage::OnChangeEditHomepageurl() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CPropertyPage::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	SetModified(TRUE);
}

BOOL CGeneralOptionPage::OnApply() 
{
  // TODO: Add your specialized code here and/or call the base class
  ClientConfiguration * pClientConfiguration = ClientConfiguration::Instance();
  strcpy(pClientConfiguration->m_Options.m_szHomePageURL, m_strHomePageURL);

  ((CTopPropertySheet *)GetParent())->SetbModified();
  g_pMainPanel->ApplyOptions(OPM_GENERAL);

  return CPropertyPage::OnApply();
}
